package com.aoyy.util.order;

import java.util.Map;
import org.apache.struts2.util.StrutsTypeConverter;
public class PaymentConverter extends StrutsTypeConverter {
  @SuppressWarnings("rawtypes")
  @Override
  public Object convertFromString(Map arg0, String[] arg1, Class arg2) {
	Payment[] payments = Payment.values();
	for (Payment payment: payments) {
	  if (payment.getName().equals(arg1[0])) {
		return payment; 
	  }
	}
	return null;
  }

  @Override
  public String convertToString(@SuppressWarnings("rawtypes") Map arg0, Object arg1) {
	return ((Payment)arg1).getName();
  }

}
